package com.android.client.view.panel;

import com.android.client.GreetingService;
import com.android.client.GreetingServiceAsync;
import com.android.client.entity.ConfEntity;
import com.android.client.event.ConfEditorStateSwitchEvent;
import com.android.client.presenter.StateSwitchPsenter;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.VerticalPanel;

public class ConfEditPanel extends VerticalPanel {
	public static final String EDITOR_TEXT = "Edit";
	public static final String SUBMIT_TEXT = "Save";
	
	private  HandlerManager mEventBus;
	private final GreetingServiceAsync greetingService = GWT
	.create(GreetingService.class);
	
	private TextArea mConfEditPanel;
	private Button mControlButton;
	private ListBox mSelector;
	
	public ConfEditPanel(HandlerManager eventBus){
		mEventBus = eventBus;
		mConfEditPanel = new TextArea();
		mConfEditPanel.setHeight("550px");
		mConfEditPanel.setWidth("950px");
		mConfEditPanel.setReadOnly(true);
		mControlButton = new Button(EDITOR_TEXT);
		mControlButton.setWidth("100px");
		mSelector = new ListBox();
		mSelector.addItem("1");
		mSelector.addItem("2");
		add(mConfEditPanel);
		add(mSelector);
		add(mControlButton);
		new StateSwitchPsenter(this, eventBus, greetingService);
		ConfEditorStateSwitchEvent mEvent = new ConfEditorStateSwitchEvent();
		mEvent.setType(ConfEditorStateSwitchEvent.LOAD_CONF);
		mEvent.setConfJdo(new ConfEntity(1L, null));
		eventBus.fireEvent(mEvent);
	}

	public TextArea getConfEdit() {
		return mConfEditPanel;
	}

	public Button getControlButton() {
		return mControlButton;
	}

	public HandlerManager getEventBus() {
		return mEventBus;
	}

	public ListBox getSelector() {
		return mSelector;
	}

}
